package com.epam.kozich;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.epam.kozich.Service.Service;
import com.epam.kozich.dao.BookDAO;
import com.epam.kozich.dao.OrderDAO;
import com.epam.kozich.dao.PersonDAO;
import com.epam.kozich.model.Book;
import com.epam.kozich.model.Order;
import com.epam.kozich.model.Person;


public class Runner {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		ApplicationContext context = new ClassPathXmlApplicationContext("resources/config.xml");
		
		Service service = (Service) context.getBean("ServiceImpl");
		
		Person person = new Person();
		person.setLogin("Dafna");
		person.setPassword("root");
		service.addNewPerson(person);
	    Book book2 = new Book();
		book2.setName("Harry Potter");
		service.saveNewBook(book2);
		Book book3 = new Book();
		book3.setName("Door in wall");
		service.saveNewBook(book3);
		Book book4 = new Book();
		book4.setName("Dorian Grey");
		service.saveNewBook(book4);
		
		Order order = new Order();
		order.setPerson(person);
		List<Book> listBook = new ArrayList<Book>();
		listBook.add(book2);
		listBook.add(book3);
		order.setBooks(listBook);
		service.addNewOrder(order);
		service.bannedPerson(person);
		service.changeBook(book3);
		service.deleteBook(book4);
		service.printBannedPerson();
		service.printBook();
		
		
		
	}

}
